<template>
  <div id="notice-wrap" class="notice-wrap" v-if="showMarquee">
    <span id="notice-text" class="notice-text">温馨提示：{{marqueeText}}</span>
    <span class="close" @click="closeMarquee"></span>
  </div>
</template>

<script>
/*
 * @Author: wuzhiying
 * @Date: 2020-07-29 14:01:56
 * @Last Modified by: wuzhiying
 * @Last Modified time: 2020-07-29 14:01:56
 */
import Vue from "vue";
export default Vue.extend({
  props: {
    marqueeText: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      showMarquee: true, // 是否展示文字滚动
    };
  },
  methods: {
    // TODO 关闭文字滚动
    closeMarquee() {
      this.showMarquee = false;
    },
  },
});
</script>

<style lang="scss">
.miniprogram-root {
  // TODO 增加小程序文字滚动样式
  .notice-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 80px;
    padding-left: 32px;
    background-color: #fffbe8;
    overflow: hidden;
    box-sizing: border-box!important;
    .notice-text {
      line-height: 80px;
      display: inline-block;
      white-space: nowrap;
      color: #ed6a0c;
      animation: 10s wordsLoop linear infinite normal;
    }
    .close {
      position: absolute;
      right: 0;
      top: 0;
      width: 60px;
      height: 80px;
      background: #fffbe8
        url(https://img.wifenxiao.com/h5-wfx/images/common/close-icon-yellow.png)
        no-repeat center;
      background-size: 24px 24px;
      z-index: 9;
    }
    @keyframes wordsLoop {
        0% {
            transform: translateX(200px);
            -webkit-transform: translateX(200px);
        }
        100% {
            transform: translateX(-800px);
            -webkit-transform: translateX(-800px);
        }
    }
    @-webkit-keyframes wordsLoop {
        0% {
            transform: translateX(200px);
            -webkit-transform: translateX(200px);
        }
        100% {
            transform: translateX(-800px);
            -webkit-transform: translateX(-800px);
        }
    }
  }
}
</style>